<?php ob_start();?>
<?php

$root = $_SERVER ['DOCUMENT_ROOT'];
// include($root.'/standart/head.php');
include ($root . '/standart/dateHeader.php');
include ($root . '/standart/checkUser.php');
$db = connect ();

if (isset ( $_GET ["CONTENT_TYPE"] )) {
	if ($_GET ["CONTENT_TYPE"] = "FIRM_ADDRESSES") {
		if (isset ( $_GET ["FIRM_ID"] )) {
			$firmId = $_GET ["FIRM_ID"];
			$stmt = "SELECT ID, ADDRESS_DEFINITION FROM ADDRESS WHERE ID IN (SELECT ADDRESS_ID FROM USERS_ADDRESS WHERE USER_ID = '$firmId')";
			$res = $db->query ( $stmt ) or die ( $stmt . "<br/><br/>" . mysql_error () );
			echo "<option value=''>Seçiniz</option>";
			while ( $row = $res->fetch_assoc () ) {
				echo '<option value="' . $row ['ID'] . '">' . $row ['ADDRESS_DEFINITION'] . '</option>';
			}
			$res->close ();
		}
	}
	if ($_GET ["CONTENT_TYPE"] = "GET_USER_INFO") {
		if (isset ( $_GET ["USER_ID"] )) {
			$userId = $_GET ["USER_ID"];
			$stmt = "SELECT * FROM GEVEZE_USER WHERE ID = $userId";
			$res = $db->query ( $stmt ) or die ( $stmt . "<br/><br/>" . mysql_error () );
			if ($row = $res->fetch_assoc ()) {
				echo '<span id="userName">' . $row ['NAME'] . '</span>';
				echo '<span id="userEmail">' . $row ['EMAIL'] . '</span>';
				
				if (! ($row ['SURNAME'] === NULL)) {
					echo '<span id="userSurName">' . $row ['SURNAME'] . '</span>';
				}
				
				if (! ($row ['RELATED_FIRM'] === NULL)) {
					echo '<span id="relatedFirmId">' . $row ['RELATED_FIRM'] . '</span>';
				}
				if (! ($row ['ISFIRM'] === NULL)) {
					echo '<span id="isFirm">' . $row ['ISFIRM'] . '</span>';
				}
			}
			$stmt = "SELECT * FROM GEVEZE_USER WHERE ID = $userId";
			$res = $db->query ( $stmt ) or die ( $stmt . "<br/><br/>" . mysql_error () );
		}
	}
}
disconnect ( $db );
?>
<?php ob_end_flush(); ?>